package cn.tedu.m3;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Consumer {
/*1.创建随机队列
* 2.绑定交换机*/
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//由服务器自动命名随机队列
            exchange = @Exchange(name = "logs",declare = "false")//declare只定义一个定义过的交换机,不在重新定义
    ))
    public void getReceive1(String msg){
        System.out.println("消费者1收动"+msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//由服务器自动命名随机队列
            exchange = @Exchange(name = "logs",declare = "false")
    ))
    public void getReceive2(String msg){
        System.out.println("消费者2收到"+msg);
    }
}
